import Vue from "vue";
import VueRouter from "vue-router";

import CreateArticle from '../views/CreateArticle'
import ListArticle from '../views/ListArticle'
import EditArticle from '../views/EditArticle'


Vue.use(VueRouter);

const routes = [{
        path: "/",
        name: "Home",
        redirect: '/articles/list'
    },
    {
        path: '/articles/list',
        name: 'articles-list',
        component: ListArticle
    },
    {
        path: '/articles/create',
        name: 'articles-create',
        component: CreateArticle
    },
    {
        path: '/articles/edit/:id',
        name: 'articles-edit',
        component: EditArticle
    }
];

const router = new VueRouter({
    routes
});
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
export default router;